<?php

$blanks_type = isset( $key[2] ) ? $key[2] : '';

$topics = app::$db->grab( 'SELECT `id`, `title` FROM `topics` ORDER BY `ord` ASC', array(), 'id' );

foreach( $topics as $topic_id => $topic )
{
  $topics[ $topic_id ]['members'] = app::$db->grab( 
    "SELECT
	R.id,
	M.leader,
	M.nickname,
	M.name,
	M.phone,
	M.city
FROM members M, requests R
WHERE
	M.request_id = R.id
	AND R.topic_id = ?
	AND M.`status` = 'approved'
	AND R.`status` =  'approved'
ORDER BY R.id, M.leader DESC",
    array( $topic_id )
    );
}

require_once HTML . 'autumn/header.php';
require_once HTML . 'autumn/cases/orgs/caves/blanks.php';
require_once HTML . 'autumn/footer.php';    

exit;
